import request, {uploadFile} from "@/utils/request";

// 获取评价数量
export async function getCommentCountServer(data) {
  return request({
    url: `/social/comment/commentCount`,
    method: 'GET',
    data,
  });
}

// 查看平均分
export async function getCommentScoreServer(data) {
  return request({
    url: `/social/comment/score`,
    method: 'GET',
    data:Object.assign({},data,{appId:'thjs_takeout_org'}),
  });
}

// 获取评价列表
export async function getCommentListServer(data) {
  return request({
    url: `/social/comment`,
    method: 'GET',
    data
  });
}

// 查看评分类型
export async function getCommentScoreTypeServer(data) {
  return request({
    url: `/social/comment/scoreType`,
    method: 'GET',
    data
  });
}

// 提交外卖评价
export async function confirmTakeoutCommentServer(data) {
  return request({
    url: `/social/comment/takeOut`,
    method: 'POST',
    data
  });
}

// 提交商城评价
export async function confirmProductCommentServer(data) {
  return request({
    url: `/social/comment/product`,
    method: 'POST',
    data
  });
}


// 提交本地生活评价
export async function confirmLocalCommentServer(data) {
  return request({
    url: `/social/comment/local`,
    method: 'POST',
    data
  });
}

// 精选评价
export async function getCommentSelectionServer(data) {
  return request({
    url: `/social/comment/selection`,
    method: 'GET',
    data
  });
}

// 上传文件
export async function commentUploadImgServer(file) {
  const res =await request({
    url: `/common/external/aliyun/getToken`,
    method: 'GET'
  })
  if(res.code==1){
    return uploadFile({
      file,
      config:res.content
    });
  }else{
    return new Promise((resolve, reject) => {
      reject({})
    })
  }
}
